home *** CD-ROM | disk | FTP | other *** search
- { This translator module component translates the TOutline, TStringGrid,
- TListView, TTreeView and TStatusBar components. }
-
- unit IvConMod;
-
- {$I IVMULTI.INC}
-
- interface
-
- uses
- Classes, Controls, IvMulti, IvDictio;
-
- type
- TIvControlModule = class(TIvModule)
- public
- function TranslateComponent(
- translator: TIvTranslator;
- component: TComponent): Boolean; override;
-
- function FlipControl(
- translator: TIvTranslator;
- control: TControl;
- state: TIvBidirectionalState): Boolean; override;
-
- function ChangeComponentReadingOrder(
- translator: TIvTranslator;
- component: TComponent): Boolean; override;
- end;
-
- implementation
-
- uses
- {$IFDEF WIN32}
- ComCtrls,
- {$ENDIF}
- Grids, Outline;
-
- function TIvControlModule.TranslateComponent(
- translator: TIvTranslator;
- component: TComponent): Boolean;
- var
- i, j, x, y: Integer;
- stringGrid: TStringGrid;
- outline: TOutline;
- {$IFDEF WIN32}
- listView: TListView;
- listItem: TListItem;
- threeView: TTreeView;
- {$ENDIF}
- begin
- if (component is TStringGrid) then
- begin
- Result := True;
- if translator.Targets.IsPropertyInTargets(component.ClassName, 'Cells') then
- begin
- stringGrid := component as TStringGrid;
-
- { Translates the fixed columns }
-
- for x := 0 to stringGrid.FixedCols - 1 do
- for y := 0 to stringGrid.RowCount - 1 do
- begin
- if ivtsPreScanning in translator.State then
- translator.AddTranslation(
- stringGrid,
- component.Name,
- 'Cells',
- stringGrid.Cells[x, y])
- else
- stringGrid.Cells[x, y] := translator.DoTranslateContextString(
- stringGrid,
- component.Name,
- 'Cells',
- stringGrid.Cells[x, y]);
- end;
-
- { Translates the fixed rows }
-
- for y := 0 to stringGrid.FixedRows - 1 do
- for x := stringGrid.FixedCols to stringGrid.ColCount - 1 do
- begin
- if ivtsPreScanning in translator.State then
- translator.AddTranslation(
- stringGrid,
- component.Name,
- 'Cells',
- stringGrid.Cells[x, y])
- else
- stringGrid.Cells[x, y] := translator.DoTranslateContextString(
- stringGrid,
- component.Name,
- 'Cells',
- stringGrid.Cells[x, y]);
- end;
- end;
- end
- else if (component is TOutline) then
- begin
- { The item range is from 1 to ItemCount }
-
- Result := True;
- if translator.Targets.IsPropertyInTargets(component.ClassName, 'Lines') then
- begin
- outline := component as TOutline;
- outline.BeginUpdate;
- for i := 1 to outline.ItemCount do
- begin
- if ivtsPreScanning in translator.State then
- translator.AddTranslation(
- outline,
- component.Name,
- 'Lines',
- outline.Items[i].Text)
- else
- outline.Items[i].Text := translator.DoTranslateContextString(
- outline,
- component.Name,
- 'Lines',
- outline.Items[i].Text);
- end;
- outline.EndUpdate;
- end;
- end
- {$IFDEF WIN32}
- else if (component is TListView) then
- begin
- Result := True;
- if translator.Targets.IsPropertyInTargets(component.ClassName, 'Items') then
- begin
- listView := component as TListView;
- for i := 0 to listView.Items.Count - 1 do
- begin
- listItem := listView.Items[i];
- if ivtsPreScanning in translator.State then
- begin
- translator.AddTranslation(
- listItem,
- component.Name,
- 'Caption',
- listItem.Caption);
- for j := 0 to listItem.SubItems.Count - 1 do
- translator.AddTranslation(
- listItem,
- component.Name,
- 'Items',
- listItem.SubItems[i]);
- end
- else
- begin
- listItem.Caption := translator.DoTranslateContextString(
- listItem,
- component.Name,
- 'Caption',
- listItem.Caption);
- translator.DoTranslateStrings(
- listItem,
- component.Name,
- 'Items',
- listItem.SubItems);
- end;
- end;
- listView.Repaint;
- end;
- end
- else if (component is TTreeView) then
- begin
- Result := True;
- if translator.Targets.IsPropertyInTargets(component.ClassName, 'Items') then
- begin
- threeView := component as TTreeView;
- for i := 0 to threeView.Items.Count - 1 do
- begin
- if ivtsPreScanning in translator.State then
- translator.AddTranslation(
- threeView,
- component.Name,
- 'Items',
- threeView.Items[i].Text)
- else
- threeView.Items[i].Text := translator.DoTranslateContextString(
- threeView,
- component.Name,
- 'Items',
- threeView.Items[i].Text);
- end;
- end;
- end
- {$ENDIF}
- else
- Result := False;
- end;
-
- function TIvControlModule.FlipControl(
- translator: TIvTranslator;
- control: TControl;
- state: TIvBidirectionalState): Boolean;
- begin
- Result := False;
- end;
-
- function TIvControlModule.ChangeComponentReadingOrder(
- translator: TIvTranslator;
- component: TComponent): Boolean;
- begin
- Result := False;
- end;
-
- begin
- Modules.Add(TIvControlModule.Create(nil));
- end.
-